package com.ics.web.controller.travelstar.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ics.framework.util.PageUtil;
import com.ics.web.controller.travelstar.domain.TiresGoods;
import com.ics.web.controller.travelstar.dto.TiresSearchDTO;
import com.ics.web.controller.travelstar.mapper.TbTiresGoodsMapper;
import com.ics.web.controller.travelstar.service.ITbTiresGoodsService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * 轮胎商品Service业务层处理
 *
 * @author ics
 * @date 2024-09-04
 */
@Service
public class TbTiresGoodsServiceImpl extends ServiceImpl<TbTiresGoodsMapper, TiresGoods>
        implements ITbTiresGoodsService {

    @Override
    public IPage<TiresGoods> listPage(TiresSearchDTO tiresSearchDTO) {
        LambdaQueryWrapper<TiresGoods> wrapper = Wrappers.lambdaQuery();
        wrapper.orderByAsc(TiresGoods::getTiresOrder);
        if (StringUtils.isNotBlank(tiresSearchDTO.getTiresType())) {
            wrapper.eq(TiresGoods::getTiresType, tiresSearchDTO.getTiresType());
        }
        return this.baseMapper.selectPage(PageUtil.getPage(tiresSearchDTO), wrapper);
    }

}
